home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / SW Demo / Demo Source / StyleHandler.c < prev    next >
Encoding:
Text File  |  1994-10-07  |  2.7 KB  |  101 lines  |  [TEXT/MPCC]

  1. // ----------------------------------------------------------------------------------
  2. // EventLoop.c
  3. // ----------------------------------------------------------------------------------
  4. // Main event loop for a standard Macintosh application
  5. //
  6. // This demo is copywrite 1994 by LexTek Internation.  Feel free to use it for
  7. // whatever purpose you wish.  The SpellWright Library may not be copied or 
  8. // distributed, except when linked to your application that adds significant features
  9. // to the code.  ie. you can't take the library, make a new library and sell it.  You
  10. // can, however, use it without royalties in applications or other such projects.
  11. //
  12. // LexTek International
  13. // 2255 N. University Parkway, Suit 15
  14. // Provo, UT 84604
  15. // (801) 375.8332  Phone
  16. // (801) 375.7654  Fax 
  17. //
  18. // ----------------------------------------------------------------------------------
  19. // History:
  20. //    9/11/94        Clark Goble    Original
  21. //
  22.  
  23.  
  24. #include "MenuHandler.h"
  25. #include "Globals.h"
  26. #include "WindowHandler.h"
  27.  
  28. void ChooseFont(short);
  29. void ChooseStyle(short);
  30.  
  31. // ----------------------------------------------------------------------------------
  32. // ChooseFont
  33. // ----------------------------------------------------------------------------------
  34. // Given a menu item this chooses the appropriate font and sets the TE selection
  35. // to that font.
  36.  
  37. void ChooseFont(short theItem)
  38. {
  39.      TEHandle     theTE;
  40.      TextStyle    theStyle;
  41.      
  42.      MenuHandle    fontMenu;
  43.      short        fontNum;
  44.      Str255        fontName;
  45.      
  46.      if (gDocWindow == nil)
  47.          return;        // no window
  48.  
  49.      theTE = (TEHandle) GetTE(gDocWindow);
  50.      
  51.      fontMenu = GetMHandle(mFont);
  52.      
  53.      GetItem( fontMenu, theItem, fontName);
  54.      
  55.      GetFNum(fontName, &fontNum);
  56.      
  57.      theStyle.tsFont = fontNum;
  58.      TESetStyle(doFont, &theStyle, true, theTE);
  59.      
  60.      return;    
  61.  
  62.  
  63. } // ChooseFont
  64.  
  65. // ----------------------------------------------------------------------------------
  66. // ChooseStyle
  67. // ----------------------------------------------------------------------------------
  68. // Given a menu item this chooses the appropriate style and sets the TE selection
  69. // to that font.
  70.  
  71. void ChooseStyle(short theItem)
  72. {
  73.  
  74.      TEHandle    theTE;
  75.      TextStyle    theStyle;
  76.      
  77.      // arrays representing the value for that menu item number
  78.      
  79.      static Style    styleTable[] = { 0, bold, italic, underline, outline, 
  80.                                      shadow, condense, extend};
  81.      static short    sizeTable[] = {9, 10, 12, 14, 18, 24};
  82.  
  83.      if (gDocWindow == nil)
  84.          return;        // no window
  85.  
  86.      theTE = (TEHandle) GetTE( gDocWindow);
  87.      
  88.      if (theItem < iline51)
  89.      {    theStyle.tsSize = sizeTable[theItem - 1];
  90.          TESetStyle(doSize, &theStyle, true, theTE);
  91.          return;
  92.      }
  93.      else if (theItem < iExtend)
  94.      {    theStyle.tsFace = styleTable[theItem - iPlain];
  95.         TESetStyle(doFace, &theStyle, true, theTE);
  96.         return;
  97.     } // if
  98. } // ChooseStyle
  99.     
  100.  
  101.